<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>青鸟影院管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/layui.css" media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/common.css">
    <script src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
</head>
<style>
.layui-body{clear: both;}
  .layui-row{float: left;}
  .imglay{background-color: #fff;width: 670px;height: 510px;margin-top: 0px;}
  .layui-panel img{width: 650px;height: 490px;}
</style>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo"><span>青鸟影院管理系统</span></div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="updateAdmin.html" >
                   	 <img src="${pageContext.request.contextPath}/img/default.png" class="layui-nav-img layui-anim layui-anim-rotate"/>
                   	 <span id="user_name"></span>
                </a>
            </li>
             <li class="layui-nav-item"><a href="adminNo">退出</a></li>
        </ul>
    </div>
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test" id="leftside">
                    <script id="side" type="text/html">
                        {{#  layui.each(d.list, function(index, item){ }}
                        <li class="layui-nav-item">
                            <a href="{{item.url}}"><i class="layui-icon {{item.icon}}"></i> {{item.name}}</a>
                        </li>
                        {{#  }); }}
                        {{#  if(d.list.length === 0){ }}
                        无数据
                        {{#  } }}
                    </script>
                </ul>
            </div>
        </div>
        
        <div class="layui-body">
            <!-- 主体区域开始 -->
            <!--当前位置开始-->
            <div class="layui-card layadmin-header">
                <span class="layui-breadcrumb">
                      <a>系统</a>
                      <a><cite>我的影厅</cite></a>
                </span>
            </div>
            <!--当前位置结束-->
            <div class="layui-row">
                <div id="system" style="width:600px;height: 490px;">
                    <div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <div class="layui-input-inline" style="width: 200px;">
                                        <input type="text" id="keyowrds" lay-verify="required" placeholder="请输入影厅名字" lay-verType="tips" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <button class="layui-btn layui-btn-radius" id="btns">
                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索
                                    </button>
                                </div>
                            </div>
                    </div>
                    <table class="layui-table">
                        <thead>
                            <tr>
                                <td><input id="btnsd" type="checkbox" title="全选"></td>
                                <td>序号</td>
                                <td>名字</td>
                                <td>席位</td>
                                <td>描述</td>
                                <td>操作</td>
                            </tr>
                        </thead>
                        <tbody id="td">
                            <c:forEach items="${halls}" var="hall">
                                <tr>
                                    <td><input type="checkbox"></td>
                                    <td>${hall.hallId}</td>
                                    <td>${hall.hallName}</td>
                                    <td>${hall.hallSeats}</td>
                                    <td>${hall.hallDescribe}</td>
                                    <td>
                                        <a href="StudioUpdate?hallId=${hall.hallId}" class="layui-btn layui-btn-xs"><i class="layui-icon layui-icon-edit"></i>修改</a>
                                    </td>
                                </tr>
                            </c:forEach>
                        </tbody>
                    </table>
                </div>

                <div id="moreMenu">
                    <a class="layui-btn layui-btn-danger layui-btn-xs" rel="1" class="user_del"><i class="layui-icon layui-icon-delete"></i>批量删除</a>
                    <a href="StudioAdd" class="layui-btn layui-btn-xs"><i class="layui-icon layui-icon-add-1"></i>添加</a>
                </div>
            </div>
            <!--主体区域结束-->
            <div class="layui-row layui-col-space15 imglay">
              <div class="layui-col-md5">
                <div class="layui-panel">
                  <img src="${pageContext.request.contextPath}/img/map.png" alt="">
                </div>   
              </div>
            </div>    
        </div>
       <div class="layui-footer" style="text-align:center">
        <!-- 底部固定区域 -->
        © 版权管理
    </div>
    </div>
<script src="${pageContext.request.contextPath}/js/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
<script src="${pageContext.request.contextPath}/js/common.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.cookie.js"></script>
<script src="${pageContext.request.contextPath}/js/urlsqit.js"></script>

    <script>

    
    $(function() {
    
    	getSearch();
	});

    
    var str = "";
	
    
    
    function getSearch() {
		$.ajax({
			 url : "/SSM_CMS/searchnews.do",
	         type : "post",
	         data:{
	        	 "title" : GetQueryString("stitle")
	         },
	         success : function (m) {
	        	 var arry = JSON.parse(m);
	        	 console.log(arry);
	        	 newslists(arry);
	        	 $('#td').append(str)
	        	 dd()
	         }
		});
		
	}    
	

    
    function newslists(arry) {
     	 for(var i = 0;i<arry.length;i++){
  		 str +="<tr>";
  		 str +="<td>"+(i+1)+"</td>"
      	 str +="<td>"+arry[i]["title"]+"</td>";
      	 str +="<td>"+arry[i]["sort"]+"</td>";
      	 str +="<td>"+arry[i]["author"]+"</td>";
      	 str +="<td>"+arry[i]["datas"]+"</td>";
      	 str +="<td>";
      	 str +="<a href='StudioUpdate?result="+arry[i]["id"]+"' class='layui-btn layui-btn-xs'><i class='layui-icon layui-icon-edit'></i>修改</a>";
         str +="<a class='layui-btn layui-btn-danger layui-btn-xs new_dels' rel='"+arry[i]["id"]+"'><i class='layui-icon layui-icon-delete'></i>删除</a>";
         str +="</td>";  
         str +="<td> <input type='checkbox' value='"+arry[i]["id"]+"'></td>"
      	 str +="</tr>";
  	 }
     	 
     	
  }
    
	$('#btnsd').click(function () {
		var $listc = $('input:checkbox');
		$listc.each(function (index, element) {
			if($listc.get(0).checked){
				$listc.get(index).checked=true;
			}else{
				$listc.get(index).checked=false;
			}
		});
	});
    
    
    
    function dd() {
        $(".new_dels").click(function(){
        	var ids = $(this).attr("rel");
            layer.open({
                icon:3,
                content:"确认删除 ID 为："+$(this).attr("rel")+" 的信息吗？",
                title:"确认删除",
                btn: ['确定', '取消'],
                yes: function(index, layero){
            		$.ajax({
           			 url : "/SSM_CMS/delnews.do",
           	         type : "post",
           	         data:{
           	        	 "result" : ids,
           	         },
           	         success : function (m) {
           	        	 var arry = JSON.parse(m);
           	        	 console.log(arry);
           	        	 if(arry.state==1){
           	        		layer.msg("删除成功",{
           	                    icon:1,time:2000
           	                });
           	        		 setTimeout("location.href='searchNews.html?stitle="+GetQueryString('stitle')+"'",1000);
           	        	 }else{
           	        		 layer.msg('删除失败', {icon: 5,time: 800});
           	        	 }
           	         }
           		});
                }
                ,btn2: function(index, layero){
                    layer.msg("已取消",{
                        icon:2,time:1000
                    });
                }
            });
            return false;
        });
	}
    


    
    

	
	
	var num = 0;
	$('#btn1').click(function () {
		var arr = "";
		var $listc = $('#td input:checkbox');
		$listc.each(function (index, element) {
	           if($listc.get(index).checked){
	        	   num++;
	        	  arr+=$(this).val()+",";//拼接值
	           }
	        });
		console.log(arr)
		if(num==0){
			 layer.msg('请先选中数据', {icon: 5,time: 800});
			 return false;
		}else{
		    layer.open({
	            icon:3,
	            content:"确认删除该"+num+"条信息吗？",
	            title:"确认删除",
	            btn: ['确定', '取消'],
	            yes: function(index, layero){
	        		$.ajax({
	       			 url : "/SSM_CMS/delsn.do",
	       	         type : "post",
	       	         data:{
	       	        	 "result" : arr
	       	         },
	       	         success : function (m) {
	       	        	 var arry = JSON.parse(m);
	       	        	 console.log(arry);
	      	        	 if(arry.state==1){
	       	        		layer.msg("删除成功",{
	       	                    icon:1,time:2000
	       	                });
	       	        		 setTimeout("location.href='news.html'",1000);
	       	        	 }else{
	       	        		 layer.msg('删除失败', {icon: 5,time: 800});
	       	        	 }
	       	         }
	       		});
	                
	            }
	            ,btn2: function(index, layero){
	            	num = 0;
	            	arr = "";
	                layer.msg("已取消",{
	                    icon:2,time:1000
	                });
	            }
	        });
		}
	});
	

	
	 $('#btns').click(function () {
	    	var tit = $('#keyowrds').val();
	    	if(tit.trim().length==0){
	    		location.href="Studio";
	    	}else{
	    		location.href="searchStudio?stitle="+tit;
	    	}
	    	
		});
    
	
    </script>
    
</body>
</html>
